package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.combat.Option;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OptionMapper extends BaseMapper<Option> {
    //根据试题的id查询选项
    @Select("SELECT * FROM tb_option WHERE question_soul_id = #{questionSoulId};")
    List<Option> findOptionById(@Param("questionSoulId") Integer questionSoulId);

    //根据试题的ID和选项的Id查询出分数
    @Select("SELECT * FROM tb_option WHERE id = #{optionId} AND question_soul_id = #{questionId}")
    Option findOptionByQidOrOId(@Param("questionId") String questionId, @Param("optionId") String optionId);

    //保存选项
    @Insert("insert into tb_option (id,option_context,score,question_soul_id) values (null, #{optionContext}, #{score}, #{questionSoulId})")
    void saveOption(Option option);
    //修改问题
    @Update("UPDATE tb_option SET option_context = #{s}  WHERE id = #{integer}")
    void updateByOptionId(@Param("integer") Integer integer, @Param("s") String s);
}
